package com.yrd.fssync.core;

import java.io.IOException;
import java.net.SocketException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class FileSystemMonitorManager {
	Context context;
	Map<String,FileSystemMonitor> fileSystemMap;
	
	public FileSystemMonitorManager(Context context) {
		this.context = context;
		context.setFileSystemMonitorManager(this);
		fileSystemMap = new HashMap<String, FileSystemMonitor>();
	}
	
	public void add(FileSystemMonitor fileSystemMonitor){
		fileSystemMap.put(fileSystemMonitor.id,fileSystemMonitor);
	}
	
	public FileSystemMonitor get(String id){
		return fileSystemMap.get(id);
	}
	
	public Map<String, FileSystemMonitor> getFileSystemMap() {
		return fileSystemMap;
	}

	public void start() throws Exception{
		for(FileSystemMonitor fileSystemMonitor : fileSystemMap.values()){
			fileSystemMonitor.start();
		}
	}
	
	public void stop() throws Exception{
		for(FileSystemMonitor fileSystemMonitor : fileSystemMap.values()){
			fileSystemMonitor.stop();
		}
	}
}
